load("//bazel:build.bzl", "redpanda_cc_library")
load("//src/v/rpc:compiler.bzl", "redpanda_cc_rpc_library")

package(default_visibility = ["//src/v/raft:__subpackages__"])

redpanda_cc_rpc_library(
    name = "raft_rpc",
    src = "raftgen.json",
    include_prefix = "raft",
)

redpanda_cc_library(
    name = "fundamental",
    hdrs = [
        "fundamental.h",
    ],
    include_prefix = "raft",
    visibility = ["//visibility:public"],
    deps = [
        "//src/v/base",
        "//src/v/model",
        "//src/v/utils:named_type",
    ],
)

redpanda_cc_library(
    name = "broker_compat",
    hdrs = [
        "broker_compat.h",
    ],
    include_prefix = "raft",
    deps = [
        "//src/v/model",
        "//src/v/reflection:adl",
        "//src/v/utils:unresolved_address",
    ],
)

redpanda_cc_library(
    name = "raft",
    srcs = [
        "append_entries_buffer.cc",
        "buffered_protocol.cc",
        "configuration_bootstrap_state.cc",
        "configuration_manager.cc",
        "consensus.cc",
        "consensus_utils.cc",
        "coordinated_recovery_throttle.cc",
        "event_manager.cc",
        "follower_stats.cc",
        "group_configuration.cc",
        "group_manager.cc",
        "heartbeat_manager.cc",
        "heartbeats.cc",
        "logger.cc",
        "offset_monitor.cc",
        "persisted_stm.cc",
        "probe.cc",
        "recovery_memory_quota.cc",
        "recovery_scheduler.cc",
        "recovery_stm.cc",
        "replicate_batcher.cc",
        "replicate_entries_stm.cc",
        "replication_monitor.cc",
        "rpc_client_protocol.cc",
        "state_machine.cc",
        "state_machine_base.cc",
        "state_machine_manager.cc",
        "types.cc",
        "vote_stm.cc",
    ],
    hdrs = [
        "append_entries_buffer.h",
        "buffered_protocol.h",
        "configuration_bootstrap_state.h",
        "configuration_manager.h",
        "consensus.h",
        "consensus_client_protocol.h",
        "consensus_utils.h",
        "coordinated_recovery_throttle.h",
        "errc.h",
        "event_manager.h",
        "follower_stats.h",
        "fundamental.h",
        "fwd.h",
        "group_configuration.h",
        "group_manager.h",
        "heartbeat_manager.h",
        "heartbeats.h",
        "logger.h",
        "mutex_buffer.h",
        "mux_state_machine.h",
        "notification.h",
        "offset_monitor.h",
        "persisted_stm.h",
        "probe.h",
        "recovery_memory_quota.h",
        "recovery_scheduler.h",
        "recovery_stm.h",
        "replicate.h",
        "replicate_batcher.h",
        "replicate_entries_stm.h",
        "replication_monitor.h",
        "rpc_client_protocol.h",
        "service.h",
        "state_machine.h",
        "state_machine_base.h",
        "state_machine_manager.h",
        "timeout_jitter.h",
        "transfer_leadership.h",
        "types.h",
        "vote_stm.h",
    ],
    include_prefix = "raft",
    visibility = ["//visibility:public"],
    deps = [
        ":broker_compat",
        ":fundamental",
        ":raft_rpc",
        "//src/v/base",
        "//src/v/bytes:iobuf",
        "//src/v/bytes:iobuf_parser",
        "//src/v/bytes:iostream",
        "//src/v/config",
        "//src/v/container:fragmented_vector",
        "//src/v/container:intrusive",
        "//src/v/features",
        "//src/v/hashing:crc32c",
        "//src/v/metrics",
        "//src/v/model",
        "//src/v/random:generators",
        "//src/v/random:time_jitter",
        "//src/v/reflection:adl",
        "//src/v/resource_mgmt:io_priority",
        "//src/v/resource_mgmt:memory_groups",
        "//src/v/rpc",
        "//src/v/serde",
        "//src/v/serde:bool_class",
        "//src/v/serde:chrono",
        "//src/v/serde:enum",
        "//src/v/serde:map",
        "//src/v/serde:optional",
        "//src/v/serde:vector",
        "//src/v/ssx:async_algorithm",
        "//src/v/ssx:future_util",
        "//src/v/ssx:semaphore",
        "//src/v/ssx:sformat",
        "//src/v/storage",
        "//src/v/storage:record_batch_builder",
        "//src/v/storage:record_batch_utils",
        "//src/v/utils:absl_sstring_hash",
        "//src/v/utils:delta_for",
        "//src/v/utils:expiring_promise",
        "//src/v/utils:human",
        "//src/v/utils:mutex",
        "//src/v/utils:named_type",
        "//src/v/utils:notification_list",
        "//src/v/utils:prefix_logger",
        "@abseil-cpp//absl/container:btree",
        "@abseil-cpp//absl/container:flat_hash_map",
        "@abseil-cpp//absl/container:flat_hash_set",
        "@abseil-cpp//absl/container:node_hash_map",
        "@boost//:container",
        "@boost//:range",
        "@fmt",
        "@seastar",
        "@yaml-cpp",
    ],
)
